from typusmotrix.data_preprocessing.font_parser import parse_fonts
from typusmotrix.data_preprocessing.dataset_builder import build_dataset
from typusmotrix.configs import base_config
import pandas as pd
import os

def main():
    base_dir = base_config.data.base_dir
    # 从配置获取路径并转为绝对路径
    raw_ttf_dir = os.path.join(base_config.data.base_dir, base_config.data.raw_ttf_dir)
    svg_dir = os.path.join(base_config.data.base_dir, base_config.data.processed.svg_dir)
    metadata_path = os.path.join(base_config.data.base_dir, "data/processed/svg_paths/metadata.csv")
    
    # 解析字体
    parse_fonts(
        raw_ttf_dir=raw_ttf_dir,
        output_svg_dir=svg_dir,
        metadata_path=metadata_path
    )
    
    # 构建数据集
    metadata = pd.read_csv(metadata_path)
    build_dataset(metadata.to_dict('records'))

if __name__ == "__main__":
    main()